package com.mew.prop.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.mew.common.dc.db.ProfileService;
import com.mew.common.dc.mapper.AccessoryMapper;
import com.mew.common.dc.mapper.MailMapper;
import com.mew.common.dc.mapper.PropMapper;
import com.mew.common.enm.GoldProcessType;
import com.mew.common.enm.MailAccessoryType;
import com.mew.common.enm.MailStatusType;
import com.mew.common.enm.ZbmType;
import com.mew.common.entity.mail.Accessory;
import com.mew.common.entity.mail.Mail;
import com.mew.common.entity.prop.Prop;
import com.mew.common.exception.ResponseCode;
import com.mew.common.rest.mail.MailBO;
import com.mew.common.rest.mail.MailDetailInfoResponseMessage;
import com.mew.common.rest.mail.MailResponseMessage;
import com.mew.provide.RegisterFeignService;
import com.mew.user.service.FriendService;
import com.zebra.common.ZbmAreaType;
import com.zebra.common.ZbmMessage;
import com.zebra.common.event.EventBusAsyncCenter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestParam;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @author dylin
 * @create 2021/4/2
 */
@Service
public class PropService {
    @Autowired
    private PropMapper propMapper;

    public long getPropNumber(long userId,int propType){
        List<Prop> props = propMapper.selectList(new LambdaQueryWrapper<Prop>()
                .eq(Prop::getUserId, userId)
                .eq(Prop::getPropTypeId, propType)
                .eq(Prop::getStatus, 0)
        );
        if(null == props){
            return 0;
        }
        return props.stream().mapToLong(Prop::getNumber).sum();
    }
    public void consume(long userId,int propType,int number){
        propMapper.consume(userId,propType,number);
    }
}
